import pika
import random
credentials = pika.PlainCredentials('admin', 'admin')
parameters = pika.ConnectionParameters('124.207.24.170',55673,'/',credentials)
while True:
    try:
        connection = pika.BlockingConnection(parameters)
    except pika.exceptions.ConnectionClosedByBroker:
        break
channel = connection.channel()
channel.queue_declare(queue='hello')
for i in range(100000):
    service = random.randint(0, 4)
    body = "{Servicename: site, logtype:identifier, logginglevel:error, operationtime:2022/2/10 12:30:49, operatorname:getIdentifier, operatortype:get, clientip:192.168.1.1, operationobject:test.txt, operationobjecttype:txt, operationaction:aggregate, operationactiontype:get, label:23, operationresult:fail}"
    channel.basic_publish(exchange='',
                          routing_key='hello',
                          body=body)
    print("service "+str(service)+" sends a log")
connection.close()
